package day13.CollectionTask;

import java.util.*;

public class TaskSix {
    public static void main(String[] args) {
        Map<Integer,String> student=new HashMap<>();
        student.put(1,"崔金甲");
        student.put(2,"汪云飞");
        student.put(3,"江河");
        student.put(4,"吴志鑫");
        student.put(5,"李亚辉");
        student.put(6,"吴志鑫");


        //根据key查询信息
        String s = student.get(2);
//        System.out.println(2+s);
        //对信息修改
        String s1 = student.put(2 , "水哥");
//        System.out.println(2+s1);
//        System.out.println(student);
//根据学号生序排序
        //        Set<Integer> integers = student.keySet();///1
//        for(Integer i:integers){
//            System.out.println(i+"="+student.get(i));
//        }
        List<Map.Entry<Integer, String>> entries = new ArrayList<>(student.entrySet());///2
        System.out.println(entries);
        entries.sort(Comparator.comparingInt(Map.Entry<Integer,String>::getKey));
//Collections.sort(entries,Comparator.comparingInt(Map.Entry<Integer,String>::getKey));    }
for(Map.Entry<Integer,String> m1:entries){
    System.out.println(m1);
}
    }
}
